<template>
    <div>
        <div class="top_tianqi">
            <div id="he-plugin-standard"></div>
            <div class="top_title">每天都要努力呀</div>
        </div>
        <div class="jiange"></div>
        <el-calendar v-model="value" />
    </div>
</template>

<script>
export default {
    data() {
        return {
            value: new Date()

        }
    },
    created() {
        this.getWeather()
    },

    methods: {
        // 和风天气插件的官网 https://widget.qweather.com/
        // key:5df369c2b5204a31b8fdddf604e2b994  和风天气的key
        // 合肥101220101
        // 舒城101221507
        // https://devapi.qweather.com/v7/weather/30d?location=101010100&key=5df369c2b5204a31b8fdddf604e2b994

        getWeather() {
            window.WIDGET = {
                "CONFIG": {
                    "layout": "1",
                    "width": "1050",
                    "height": "120",
                    "background": "1",
                    "border-radius": "10",
                    // "dataColor": "FFFFFF",
                    "dataColor": "FFFFFF",
                    "key": "24fdf400ed0c4be7bd24a1d180241938",
                    "city": '101220101'
                }
            }
            var script = document.createElement('script');
            script.type = 'text/javascript';
            script.src = 'https://widget.qweather.net/standard/static/js/he-standard-common.js?v=2.0';
            document.getElementsByTagName('head')[0].appendChild(script);
            this.hideElements();
        },
        hideElements() {
            this.$nextTick(() => {
                setTimeout(() => {
                    const updatedContainer = document.querySelector('.wv-v-h-row');
                    updatedContainer.addEventListener('click', function (event) {
                        if (event.target.tagName === 'DIV' || event.target.tagName === 'A' || event.target.tagName === 'IMG' || event.target.tagName === 'SPAN' || event.target.tagName === 'LI') {
                            event.preventDefault(); // 阻止默认跳转行为
                            return false; // 阻止默认行为
                        }
                    });
                }, 500);
            });
        }

    }
}
</script>

<style lang="scss" scoped>
.top_tianqi{
    display: flex;
    // justify-content: space-between;
    align-items: center;
    .top_title{
        margin-left: 20px;
    }
}
.jiange {
    height: 10px;
}

:deep .el-calendar-day {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}
</style>